/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.uefs.cedoc.controle.estante;

import br.uefs.cedoc.db.estante.DBEstante;

/**
 *
 * @author suporte
 */


import br.uefs.cedoc.controle.*;
import br.uefs.cedoc.db.exception.DBConnectionException;
import javax.servlet.*;
import javax.servlet.http.*;
import br.uefs.cedoc.db.*;
import br.uefs.cedoc.db.estante.DBEstante;
import br.uefs.cedoc.entidades.*;
import java.sql.SQLException;
  
public class GetEstanteCommand implements Command {
  private String next;

  public GetEstanteCommand(String next) {
    this.next = next;
  }

    public String execute(HttpServletRequest req)
    throws CommandException {
        try {
            
            DBEstante dbestante = new DBEstante();
            EstanteBean estante = new EstanteBean();  
            
            int idEstante = Integer.parseInt(req.getParameter("id"));
            
            
            HttpSession session = req.getSession(true);
            SerieBean serie = (SerieBean)session.getAttribute("serie");
            System.out.println("IDSERIE="+serie.getIdSerie());
            estante = dbestante.getEstanteSerie(idEstante,serie.getIdSerie());
            System.out.println("ID ESTANTE "+ estante.getIdEstante());
            System.out.println("DESCRICAO="+estante.getEstante());
            System.out.println("ID SERIE="+estante.getIdSerie());
            req.setAttribute("estante",estante);

            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (DBConnectionException ex) {
                ex.printStackTrace();
            }

            req.setAttribute("status.msg", "tetes");
            
            return next;

    }
}


